﻿using mak_bll;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace markets
{
    public partial class admincha : Form
    {
        public admincha()
        {
            InitializeComponent();
        }
        luoji lj = new luoji();
        private void admincha_Load(object sender, EventArgs e)
        {
            dataGridView1.DataSource = lj.xianshi();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            dataGridView1.DataSource = lj.ytjxianshi(txtaname.Text);
        }

        private void 删除员工ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int selectCount = dataGridView1.SelectedRows.Count;//获取选中行的数量
            if (selectCount != 1)
            {
                MessageBox.Show("请选择要修改的一行数据"); return;
            }

            DataGridViewRow dr = dataGridView1.SelectedRows[0];
            string adminid = dr.Cells["Column1"].Value.ToString();

            int co = lj.shanchu(adminid);
            if (co == 1)
            {
                MessageBox.Show("删除成功");
                admincha_Load(null, null);
            }
            else
            {
                MessageBox.Show("删除数据失败");
            }

        }

        private void 修改员工ToolStripMenuItem_Click(object sender, EventArgs e)
        {

            
            //int selectCount = dataGridView1.SelectedRows.Count;//获取选中行的数量
            //if (selectCount != 1)
            //{
            //    MessageBox.Show("请选择要修改的一行数据"); return;
            //}

            //DataGridViewRow dr = dataGridView1.SelectedRows[0];
            //string adminid = dr.Cells["Column1"].Value.ToString();

            //upyuan y = new upyuan(Convert.ToInt32(adminid));
            //y.ShowDialog();
        }
    }
}
